package com.design03_behavioral.pattern20_memento.example01;

/**
 * @ClassName Client
 * @Description TODO
 * @Author 22963
 * @DATE 2023/9/10 12:36
 */
public class Client {

    public static void main(String[] args) {
        //创建发起人对象
        Originator originator = new Originator();
        originator.setId("1");
        originator.setName("spike");
        originator.setPhone("13512341234");
        System.out.println("=============" + originator);

        //创建负责人对象,并保存备忘录对象
        Caretaker caretaker = new Caretaker();
        Memento memento = originator.create();
        caretaker.setMemento(memento);


        //修改
        originator.setName("update");
        System.out.println("=============" + originator);


        //从负责人对象中获取备忘录对象,实现撤销
        originator.restore(caretaker.getMemento());
        System.out.println("=============" + originator);
    }

}
